package com.hzh.reverse.server;

import com.hzh.reverse.server.handler.ClientConnectionInitializer;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

public class MainServer {
    public static void main(String[] args) throws InterruptedException {
        EventLoopGroup boss=new NioEventLoopGroup(1);
        EventLoopGroup worker=new NioEventLoopGroup();

    try{
        ServerBootstrap b=new ServerBootstrap();
        b.group(boss, worker).channel(NioServerSocketChannel.class)
        .handler(new LoggingHandler(LogLevel.INFO))
        .childHandler(new ClientConnectionInitializer())
        .bind(8081).sync().channel().closeFuture().sync();
    }
    finally{
        boss.shutdownGracefully();
        worker.shutdownGracefully();
    }


    }
}
